package com.pd.backend.vo.resp;

import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @ClassName GetPageVo
 * @Description TODO
 * @date 2023/2/28 19:50
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GetPageVo<T> {
    /*
    总条数
     */
    private Integer counts;
    /*
    每页最多几条
     */
    private Integer pagesize;
    /*
    多少页
     */
    private Integer pages;
    /*
    页码
     */
    private Integer page;
    private List<T> items;


    /**
     * 分页数据组装
     * @param pageInfo
     * @return
     */
    public GetPageVo(PageInfo<T> pageInfo) {
        counts = Integer.parseInt(String.valueOf(pageInfo.getTotal()));
        pages = pageInfo.getPages();
        page = pageInfo.getPageNum();
        pagesize = pageInfo.getPageSize();

        items = pageInfo.getList();
    }
}
